package util

import "log"

func PanicIfErr(err error) {
	if err != nil {
		log.Println("panic --> ", err)
		panic(err)
	}
}

func LogIfErr(err error) {
	if err != nil {
		log.Println("err --> ", err)
	}
}
func HashIndex(key string, dx int) int {
	return abs(javaHashCode(key)) % dx
}
func abs(i int32) int {
	if i < 0 {
		return int(-i)
	} else {
		return int(i)
	}
}
func javaHashCode(val string) int32 {
	h := int32(0)
	codes := []byte(val)
	for _, v := range codes {
		h = 31*h + int32(v)
	}
	return h
}
